package org.looop.studio.noots.analyzer;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class MockSynonymEngine implements SynonymEngine {

	private static List<Set<String>> synonymSet = new ArrayList<Set<String>>();
	
	static {
		addSynonym(new String[]{"fast", "speedy", "quick"});
		addSynonym(new String[]{"leaps", "hops", "jumps"});
		addSynonym(new String[]{"above", "over"});
		addSynonym(new String[]{"apathetic", "sluggish", "lazy"});
		addSynonym(new String[]{"canines", "pooches", "dogs"});
	}
	
	@Override
	public String[] getSynonyms(String s) {
		for (Set<String> synonym : synonymSet) {
			if(synonym.contains(s)){
				ArrayList<String> list = new ArrayList<String>();
				for(String str : synonym){
					if(!str.equals(s)){
						list.add(str);
					}
				}
				if(list.size() > 0){
					return list.toArray(new String[]{});
				}
			}
		}
		return null;
	}

	private static void addSynonym(String[] strings) {
		Set<String> set = new HashSet<String>();
		for (String string : strings) {
			set.add(string);
		}
		synonymSet.add(set);
	}

}
